package Lab07.Q3;

public interface IShapeFactory {
    Shape makeShape(double a, double b);
}

class RhombusFactory implements IShapeFactory {
    private static final RhombusFactory factory = new RhombusFactory();

    public static RhombusFactory getFactory() {
        return factory;
    }

    public Shape makeShape(double a, double b) {
        if (a < 0 || b < 0)
            return null;
        return new Rhombus(a, b);
    }
}

class EllipseFactory implements IShapeFactory {
    private static final EllipseFactory factory = new EllipseFactory();

    public static EllipseFactory getFactory() {
        return factory;
    }

    public Shape makeShape(double a, double b) {
        if (a < 0 || b < 0)
            return null;
        return new Ellipse(a, b);
    }
}

class RectangleFactory implements IShapeFactory {
    private static final RectangleFactory factory = new RectangleFactory();

    public static RectangleFactory getFactory() {
        return factory;
    }

    public Shape makeShape(double a, double b) {
        if (a < 0 || b < 0)
            return null;
        return new Rectangle(a, b);
    }
}